package com.x.erp.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.x.erp.dao.MultilevelActivityBuyDao;
import com.x.erp.manage.MultilevelActivityBuyManage;
import com.x.erp.model.MultilevelActivityBuy;
import com.x.erp.rpc.MultilevelActivityBuyRpcService;
import com.x.framework.controller.ResultModel;
import com.x.framework.exception.BusinessException;
import com.x.framework.exception.ExceptionCode;
import com.x.framework.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 多级营销活动购买记录服务
 */
@Component
@Service(interfaceName = "com.x.erp.rpc.MultilevelActivityBuyRpcService", timeout = 60000)
public class MultilevelActivityBuyService extends BaseService implements MultilevelActivityBuyRpcService {

	@Autowired
	private MultilevelActivityBuyDao multilevelActivityBuyDao;//多级营销活动购买记录信息DAO

	@Autowired
	private MultilevelActivityBuyManage multilevelActivityBuyManage;//多级营销活动购买记录信息Manage

	/**
	 * 查询多级营销活动购买记录列表
	 * @param multilevelActivityBuy
	 * @return
	 */
	@Override
	public List<MultilevelActivityBuy> selectMultilevelActivityBuyList(MultilevelActivityBuy multilevelActivityBuy){
		try {
			return multilevelActivityBuyDao.selectMultilevelActivityBuyList(multilevelActivityBuy);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 查询多级营销活动购买记录数量
	 * @param multilevelActivityBuy
	 * @return
	 */
	@Override
	public int selectMultilevelActivityBuyNum(MultilevelActivityBuy multilevelActivityBuy){
		try {
			return multilevelActivityBuyDao.selectMultilevelActivityBuyNum(multilevelActivityBuy);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 新增多级营销活动购买记录信息
	 * @param multilevelActivityBuy
	 * @return
	 */
	@Override
	public MultilevelActivityBuy insertMultilevelActivityBuy(MultilevelActivityBuy multilevelActivityBuy){
		try {
			return multilevelActivityBuyManage.insertMultilevelActivityBuy(multilevelActivityBuy);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 修改多级营销活动购买记录信息
	 * @param multilevelActivityBuy
	 * @return
	 */
	@Override
	public int updateMultilevelActivityBuy(MultilevelActivityBuy multilevelActivityBuy){
		try {
			return this.update(multilevelActivityBuy);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	@Override
	public int deleteMultilevelActivityBuy(MultilevelActivityBuy multilevelActivityBuy) {
		try {
			return this.delete(multilevelActivityBuy);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	@Override
	public ResultModel updateDeal(MultilevelActivityBuy multilevelActivityBuy, String shopId, String saleUserId) {
		try {
			return multilevelActivityBuyManage.updateDeal(multilevelActivityBuy, shopId, saleUserId);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

}
